package com.nattakute.formatter;

import java.text.ParseException;
import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;

import com.nattakute.model.Status;
import com.nattakute.service.StatusService;


@Component("statusFormatter")
public class StatusFormatter implements Formatter<Status> {

	@Autowired(required=true)
	@Qualifier("statusService")
	private StatusService statusService;
	
	public String print(Status status, Locale locale) {
		// TODO Auto-generated method stub
		return status.getStatusName().toString();
	}

	public Status parse(String string, Locale locale) throws ParseException {
		// TODO Auto-generated method stub
		return statusService.getStatusById(Integer.parseInt(string));
	}
	
	
}
